package com.fbooks.Controller;

import com.alibaba.fastjson.JSONObject;
import com.fbooks.bean.Logger;
import com.fbooks.bean.User;
import com.fbooks.service.LoggerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: LuoRunFeng
 * @Email: 475403147@qq.com
 * @Time: 2020/6/14 0014 20:31
 * @Team: 蜂鸟工作室
 */
@CrossOrigin
@Controller
@RequestMapping("logger")
public class LoggerController {


    @Autowired
    private LoggerService loggerService;

    @RequestMapping("all")
    @ResponseBody
    public PageInfo<Logger> getAllLogger(@RequestBody JSONObject jsonObject){
        //获取川谷来的数据
        Integer pages =  Integer.valueOf(jsonObject.getString("page"));
        Integer pageNum = Integer.valueOf(jsonObject.getString("pageSize"));
        PageHelper.startPage(pages,pageNum);

        List<Logger> loggerList = loggerService.getAllLogger();

        PageInfo<Logger> pageInfo = new PageInfo<>(loggerList);

        return pageInfo;
    }
}
